package board;

import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import game.DataStore;
import misc.Vector3i;

public abstract class BoardUtil {
    public static final float DISTANCE_CARDINAL_1 = 1f;
    public static final float DISTANCE_DIAGONAL_1 = FastMath.sqrt(2);
    public static final float DISTANCE_CARDINAL_2 = 2f;
    public static final float DISTANCE_OFFDIAGONAL_1 = FastMath.sqrt(5);
    public static final float DISTANCE_DIAGONAL_2 = FastMath.sqrt(8);
    public static final float DISTANCE_CARDINAL_3 = 3f;
    public static final float DISTANCE_OFFDIAGONAL_2 = FastMath.sqrt(13);
    
    //fun mathematical calculations
    @Deprecated
    public static Vector3i worldToBoard(Vector3f worldLocation) {
	//right now this only works if Tile.SIZE > 1
        //not sure if this function works at all
	Vector3i boardLocation = new Vector3i();
	float offsetX = Tile.SIZE*FastMath.sign(worldLocation.getX());
	float offsetY = Tile.SIZE*FastMath.sign(worldLocation.getY());
	float offsetZ = Tile.SIZE*FastMath.sign(worldLocation.getZ());
	boardLocation.setX((int)((worldLocation.getX() + offsetX)/(Tile.SIZE)));
	boardLocation.setY((int)((worldLocation.getY() + offsetY)/(Tile.SIZE)));
	boardLocation.setZ((int)((worldLocation.getZ() + offsetZ)/(Tile.SIZE)));
	return boardLocation;
    }

    public static Vector3f boardToWorld(Vector3i boardLocation) {
	return DataStore.board.getTile(boardLocation).getWorldTranslation();
    }
}
